/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2022并保留所有权利。
 * Copyright 2022, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.hash.map.test.othermap.test;

import java.util.*;

public class MapExample {
    public static void main(String args[]) {
        String ars1[] = {"11","5"};
        String ars11[] = {"prescribed=1","a=1","time=2","any=1","no=1","shall=1","nor=1","peace=1","owner=1","soldier=1","to=1","the=2","law=1","but=1","manner=1","without=1","house=1","in=4","by=1","consent=1","war=1","quartered=1","be=2","of=3"};
        String ars[] = {"prescribed","prescribed","any","any","any","shall","nor","peace","owner","soldier","to","the","law","but","manner","without","house","in","by","consent","war","quartered","be","of"};
        Map map = new HashMap();
        Integer ONE = new Integer(1);
        System.out.println("----：" + ars.length);
        for (int i = 0, n = ars.length; i < n; i++) {
            String key = ars[i];
            Integer frequency = (Integer) map.get(key);
            if (frequency == null) {
                frequency = ONE;
            } else {
                int value = frequency.intValue();
                frequency = new Integer(value + 1);
            }
            map.put(key, frequency);
        }
        System.out.println(map);
        Map sortedMap = new TreeMap(map);
        System.out.println(sortedMap);
    }
}
